<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	
	
	
	<xsl:template match="Class">
	
		<xsl:variable name="Name" select="LName"/>
		
-- Working on <xsl:value-of select="Name"/>

DROP TABLE `<xsl:value-of select="LName"/>`;

CREATE TABLE `<xsl:value-of select="LName"/>` (
	`id` int(10) unsigned NOT NULL auto_increment,
		<xsl:for-each select="ClassAttribs/ClassAttributes">
			<xsl:if test="CType='single' and KnownClass='false'">
	`<xsl:value-of select="Name"/>` <xsl:value-of select="SqlType"/> default NULL,</xsl:if>
			<xsl:if test="CType='single' and KnownClass='true'">
	`<xsl:value-of select="Name"/>_id` int(10) unsigned default NULL,</xsl:if>
	</xsl:for-each>
	`created` DATETIME NOT NULL,
	`modified` DATETIME NOT NULL,
	PRIMARY KEY (`id`)
) TYPE = MyISAM;





		<xsl:for-each select="ClassAttribs/ClassAttributes">
			<xsl:if test="CType='array'">
CREATE TABLE `<xsl:value-of select="$Name"/>s_<xsl:value-of select="LName"/>` (
	`<xsl:value-of select="$Name"/>_id` int(10) unsigned NOT NULL default '0',	
	`_<xsl:value-of select="LType"/>_id` int(10) unsigned NOT NULL default '0',
	PRIMARY KEY (`<xsl:value-of select="$Name"/>_id` , `_<xsl:value-of select="LType"/>_id`)
) TYPE = MyISAM;
		
		
			</xsl:if>
		</xsl:for-each>
		
-- End work on <xsl:value-of select="Name"/>
	</xsl:template>
	
	
	
</xsl:stylesheet>